<html>
	<head>
		<meta charset="utf-8">
		<title>Razdavalnik</title>
		<link rel="shortcut icon" href="shopping.icon">
		<link rel="stylesheet" href="css/bootstrap.min.css" >
		<link rel="stylesheet" href="css/bootstrap-theme.min.css" > 
		 <script src="lib/jquery.min.js"></script>
 		 <script src="js/bootstrap.min.js"></script>
		<script type="text/javascript" src="js/page1.js"></script>
		<script src="js/profile-settings.js"></script>
		
		<script>window.onload=getActivity();</script>
		<script>
		 	function addCategories(){
		 		$.get("http://localhost:8080/Prodavalnik/getCategory?name=root",function(data){
		 			var values=data.split('!');
		 			$('#ChoseCategory').html($('#ChoseCategory').html() + values[1]);
		 	});
		 	}
		 </script>
		 <script>
		 function NextCategory(id,data){
		 		var html = $('#'+id).html();
		 		$.get("http://localhost:8080/Prodavalnik/getCategory?name="+data,function(data1){
		 			
		 			var values=data1.split('!');
		 			if(data1.indexOf("id")==-1){
		 				var label = "<input type=\"text\" name='category' value='"+data+"'/>";
		 				$('#ChoseCategory').html($('#ChoseCategory').html() + label);
		 				
		 			}
		 			
					
					var start = values[1].indexOf("id='");
		 			var nextString=values[1].substr(values[1].indexOf("id='")+4,10);
		 			var exist = nextString.substr(0,nextString.indexOf("'"));
		 			
					if(html.indexOf(exist)>-1)
		 			{
						$('#'+id).find('ul').remove();
		 			}				
		 		else{
		 				$('#'+id).html(html + values[1]);
		 			}
		 		}
		 		);
		 	}
		 
		 </script>
	</head>

	<body onload = "Change()">
	

<!-- Navigation Bar -->
	<div class="navbar navbar-inverse navbar-static-top">
        <div class="container -fluid">
			<div class = "navbar-header-inverse">
			<a href="page1.html"><button style="font-family:Gentium Basic;" type="button" class="btn navbar-brand navbar-btn" data-toggle="collapse" data-target=".navbar-collapse" >
				  <span class="icon-bar"></span>
				  <span class="icon-bar"></span>
				  <span class="icon-bar"></span>
				  <font color="#428bca">Razdavalnik</font> 
				</button>	</a>
			</div>
			
			 			 <!--Profile and Log out buttons -->
			<div class = "navbar-collapse collapse" >
				<ul class="nav navbar-nav navbar-right">
					<li class="dropdown">
					  <a class="dropdown-toggle" role="button" data-toggle="dropdown" href="#"><i class="glyphicon glyphicon-user"></i> Profile <span class="caret"></span></a>
					  <ul id="g-account-menu" class="dropdown-menu" role="menu">
						<li>
							<a data-toggle="modal" data-target="#myModal">
								 Make a new ad
							</a>
							<a data-toggle="modal" href="#changeProfile">
								Change Profile
							</a>
						</li>
					  </ul>
					</li>
					<li><a href="page1.html">
							<span class="glyphicon glyphicon-lock"></span> Logout</a>
						</li>
				  </ul>			
			</div>	
		</div>
    </div>
	
		
		<!-- Modal Dialogue Window When you click Make a new ad -->
		<!-- Modal Dialogue Window When you click Make a new ad -->
		<!-- Modal Dialogue Window When you click Make a new ad -->
		<!-- Modal Dialogue Window When you click Make a new ad -->
	
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<form action="http://localhost:8080/Prodavalnik/NewADServlet" method="post" enctype="multipart/form-data">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					<h1 class="modal-title text-center" id="myModalLabel">New Product</h1>
				</div>
					<div class="modal-body">
							 <!-- Name of the product-->
						<div class="control-group text-center">
								
								<label class="control-label" for="textinput">Name of product:</label>
								<div class="controls">
								  <input id="prod-name-reg" name="name-input" type="text" placeholder="" class="input-medium">
								</div>
								<br/>
						  <!-- Price of the product-->
							<label class="control-label" for="textinput">Price of the product:</label>
							<div class="controls">
							  <input id="prod-price-reg" name="price-input" type="text" placeholder="" class="input-medium">
							</div>
						 <!-- Description of category -->
						 <label class="control-label" for="textinput">Category:</label>
						 <div id="ChoseCategory" class="controls">
						 <input type="button" onclick="addCategories()" value="chose category"/>
						
						 </div>
						
						  <!-- Description of Product-->
							<label class="control-label" for="textinput">Product description:</label>
							<div class="controls">
								<textarea id="prod-descr-reg" name="desc-input" placeholder="" class="input-medium"></textarea>
							</div>
							<br/>
						  <!-- Drag and Drop for images-->
						  <!-- NEED MORE WORK -->
							<label class="control-label" for="textinput">Upload picture of the product:</label>
							<div id="Images" class="controls">
							
								<input id="prod-image-reg1" name="imageinput" type="file" class="input-medium">
								
								
							</div>
						</div>
						<br/>
						<div class="modal-footer">
							<input type="submit" class="btn btn-success" value="Submit" />
							<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
					    </div>
				</div>
			</div>
		</div>
		</form>
	</div>

	<!-- END of Modal Dialogue Window When you click Make a new ad -->
	<!-- END of Modal Dialogue Window When you click Make a new ad -->
	<!-- END of Modal Dialogue Window When you click Make a new ad -->
	<!-- END of Modal Dialogue Window When you click Make a new ad -->
	
						
				 <!-- SETTINNGS -->
				 <div class="col-sm-9" align="center">
			
					 <div class="tab-pane" id="changeProfile">					
					  <hr>
					  <h2 align="center">Change profile</h2>
					  <form class="form" action="profile-settings.html" method="post" id="registrationForm">
						  
						 <div class="form-group">
							  <!-- EMAIL -->
							  <div class="col-xs-6" align="center">
								<h4><label for="email">Email</label></h4>
								  <input type="email" class="form-control" name="email" id="email" placeholder="you@email.com" title="enter your email.">
							  </div>
						  </div>
						  
					  <div class="form-group">
						  <!-- Address-->
							  <div class="col-xs-6" align="center">
								<h4><label for="address">Address</label></h4>
								  <input type="text" class="form-control" name="address" id="address" placeholder="enter address" title="enter your address.">
							  </div>
						  </div>
						  
						  <div class="form-group">
							  <!-- PHONE -->
							  <div class="col-xs-6" align="center">
								 <h4><label for="phone">Phone</label></h4>
								  <input type="text" class="form-control" name="phone" id="phone" placeholder="enter phone" title="enter your phone number if any.">
							  </div>
						  </div>
			  
						  <div class="form-group">
							  <!-- PASSWORD -->
							  <div class="col-xs-6" align="center">
								  <h4><label for="password">Password</label></h4>
								  <input type="password" class="form-control" name="password" id="password" placeholder="password" title="enter your password.">
							  </div>
						  </div>
						  <div class="form-group">
							  <!-- PASSWORD AGAIN -->
							  <div class="col-xs-6" align="center">
								<h4 ><label for="password2">Verify</label></h4>
								  <input type="password" class="form-control" name="password2" id="password2" placeholder="password2" title="enter your password2.">
							  </div>
						  </div>
						  <div class="form-group">
						  <!-- BUTTONS SAVE and RESET -->
							   <div class="col-xs-12">
									<br>
									<button class="btn btn-lg btn-success" type="button" onclick="changeProfile()"><i class="glyphicon glyphicon-ok-sign"></i> Save</button>
									<button class="btn btn-lg btn-success" type="reset">Refresh Form </button>
									<button class="btn btn-lg btn-success" type="submit"> Cancel</button>							
								</div>
						  </div>
					</form>
				  </div><!-- close setting -->
				   
				 
			   </div><!--/tab-content--> 

		<br/><br/><br/>

	</body>
</html>